/**
 * Created by luckyjing on 16/3/24.
 */
var Articles = require('../../app/controllers/article.server.controller');
var Util = require('../util/util');
var hasAuth = Util.hasAuthorization(function (req, res) {
    if (req.articles.creator == req.user) {
        return true;
    } else {
        return false;
    }
});
module.exports = function (app) {
    app.route('/api/articles')
        .get(Articles.list)
        .post(Util.requireLogin, Articles.create);

    app.route('/api/articles/:articleId')
        .get(Articles.read)
        .post(Util.requireLogin,Articles.update);
    
    //在对具体文章进行访问时,将其纳入到请求中
    app.param('articleId', Articles.articleByID);
};